﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace ETask.Client.ViewModels
{
    public class RegisterViewModel : ViewModelBase
    {

        private bool _hasRegistered;
        
        public bool HasRegistered
        {
            get => _hasRegistered;
            set
            {
                SetProperty(ref _hasRegistered, value);
                UpdateDisplayText();
            }
        }

        private string _displayRegistered;

        public string DisplayRegistered
        {
            get => _displayRegistered;
            set => SetProperty(ref _displayRegistered, value);
        }

        public ICommand CancelCommand { get; }

        public event EventHandler CloseRequested;


        private void UpdateDisplayText()
        {
            DisplayRegistered = HasRegistered ? "已注册" : "未注册";
        }


        public RegisterViewModel()
        {
            CancelCommand = new RelayCommand(CloseWindow);
            UpdateDisplayText();
        }

        private void CloseWindow()
        {
            if (CloseRequested != null)
            {
                CloseRequested(this, EventArgs.Empty);
            }
        }
    }
}
